﻿// Author:					Joe Audette
// Created:					2010-12-11
// Last Modified:			2010-12-11
// 
// The use and distribution terms for this software are covered by the 
// Common Public License 1.0 (http://opensource.org/licenses/cpl.php)  
// which can be found in the file CPL.TXT at the root of this distribution.
// By using this software in any fashion, you are agreeing to be bound by 
// the terms of this license.
//
// You must not remove this notice, or any other, from this software.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace mojoPortal.Web.Modules
{
    public partial class LoginModule : SiteModuleControl
    {
        // FeatureGuid 12c68a12-ceea-4d29-8a81-2db8f2e9d29b

        #region OnInit

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            this.Load += new EventHandler(Page_Load);

        }

        #endregion

        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.IsAuthenticated)
            {
                this.Visible = false;
                return;
            }

            LoadSettings();
            PopulateLabels();
            PopulateControls();

        }

        private void PopulateControls()
        {
            
            TitleControl.Visible = !this.RenderInWebPartMode;
            if (this.ModuleConfiguration != null)
            {
                this.Title = this.ModuleConfiguration.ModuleTitle;
                this.Description = this.ModuleConfiguration.FeatureName;
            }


        }


        private void PopulateLabels()
        {
            
        }

        private void LoadSettings()
        {
            if (!SiteUtils.IsSecureRequest())
            {
                if (WebConfigSettings.ShowWarningWhenSslIsAvailableButNotUsedWithLoginModule)
                {
                    bool sslIsAvailable = SiteUtils.SslIsAvailable();
                    lblSslWarning.Visible = sslIsAvailable;
                }

            }

        }


    }
}
